package com.bike.enumItem;

import java.util.HashMap;
import java.util.Map;

public enum ResultCodeEnum {
	SUCCESS(0,""),
	ERROR(1,"操作失败"),
	RE_REPEAT(101,"该单车已经被别人预约"),
	Re_SELF_REPEAT(102,"您已经有一辆预约中的单车了"),
	RE_MAX_COUNT(103,"预约车辆次数已超过当日预约总次数"),
	Re_SELF_RUN(104,"正在骑行中,不允许在预约车辆"),
	bike_error(201,"车辆异常"),
	Phone_error(301,"手机号码格式错误"),
	Phone_Code_error(302,"手机验证码输入错误"),
	Phone_Code_ErpTime(303,"验证码已经失效"), 
	U_ACCOUNT_ERROR(7000,"账号失效,请重新登录"),
	U_NO_ACCOUNT_ERROR(1001,"无押金可退"),
	U_NO_MONEY_ERROR(1002,"余额不足"),
	U_ACCOUNT_TIMEOUT(7000,"账号失效,请重新登录"),
	U_NO_VREAL_ERROR(1003,"请先实名认证!"),
	U_NO_Deposit_ERROR(1004,"请交纳押金!"),
	PARAM_ERROR(8000,"非法操作"),
	SELECT_ERROR(2000,"查询失败"),
	SYS_ERROR(4000,"系统异常"),
	INVI_ERROR(6000,"只能修改一次邀请码"),
	CODE_ERROR(5000,"验证码错误"),
	ISRUN(666,"骑行中"),
	UPDATE_ERROR(3000,"更新失败") ;
	
	int code;
	String msg;
	
	ResultCodeEnum(int code,String msg){
		this.code=code;
		this.msg=msg;
	}
	public int getCode(){
		return code;
	}
	public static String getMsg(int code){
		for(ResultCodeEnum rce:ResultCodeEnum.values()){
			if(rce.code==code){
				return rce.getMsg();
			}
		}
		return "";
	}
	public String getMsg(){
		return msg;
	}
	public static Map<String,Object> getMapForCode(ResultCodeEnum codeEnum){
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("code", codeEnum.code);		
		map.put("message", codeEnum.msg);
		return map;
	}
}
